package com.jt.tenant.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.amap.api.services.core.LatLonPoint;
import com.jt.tenant.R;
import com.jt.tenant.app.JTApplication;

import java.util.List;

/**
 * Created by Administrator on 2016/4/22.
 */
public class NavigationAddressAdapter extends BaseAdapter {

    private Context context;

    private List<Info> list;

    public NavigationAddressAdapter(Context context, List<Info> list) {

        this.context = context;

        this.list = list;
    }

    @Override
    public int getCount() {

        return list.size();

    }

    @Override
    public Object getItem(int position) {

        return list.get(position);

    }

    @Override
    public long getItemId(int position) {

        return position;

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        Info info = (Info) getItem(position);

        ViewHolder holder = null;

        if(convertView == null){

            convertView = View.inflate(context, R.layout.item_navigation_address,null);

            JTApplication.ScaleScreenHelper.loadView((ViewGroup)convertView);

            holder = new ViewHolder();

            holder.tv_address = (TextView) convertView.findViewById(R.id.tv_address);

            convertView.setTag(holder);

        }else{

            holder = (ViewHolder) convertView.getTag();

        }

        holder.tv_address.setText(info.title);

        return convertView;

    }

    class ViewHolder{

        TextView tv_address;

    }

    public static class Info{

        public String city = "", title = "", content = "", number = "";

        public LatLonPoint latLonPoint;

    }
}
